<?php
	header('Content-type: text/json;charset=utf-8');
	require_once("json.php");
	error_reporting(E_ALL ^ E_DEPRECATED);

	$returnArray = array();
	
	define('DB_HOST',SAE_MYSQL_HOST_M);
	define('DB_USER',SAE_MYSQL_USER);
	define('DB_PWD',SAE_MYSQL_PASS);
	define('DB_NAME',SAE_MYSQL_DB);
	$con =mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
	if (!$con)
    {
  		$returnArray['status']="success";
  		$returnArray['msg']='Could not connect: ' . mysql_error();
  		$resJson = json_encode($returnArray);
		echo $resJson."\n";
  		return 0;
  	}
	mysql_select_db("app_tagwall", $con);
	mysql_query("set names utf8");

	$retSql = "select * from tmc_tag order by date DESC";
	$reta=mysql_query( $retSql, $con);
	while ($record = mysql_fetch_assoc($reta)) {
		$returnArray['reta'][]=$record;
	}
	mysql_close($con);
	$resJson = json_encode($returnArray);
	echo $resJson."\n";

?>